import { createStore } from "vuex";

import user from "./modules/user";
import common from "./modules/common";
import business from "./modules/business";
import shoppingCard from "./modules/shopping-card";
import dicts from "./modules/dicts";
import print from "./modules/print";
import face from "@/common/init/face/store/face";

export default createStore({
  modules: {
    print,
    business,
    user,
    common,
    shoppingCard,
    dicts,
    face,
  },
  state: {},
  mutations: {
    clearState(state: any) {
      console.log("clearState", state);
      Object.keys(state).forEach((key) => {
        state[key] = null;
      });
    },
  },
  getters: {
    isLogin: (state) => !!state.user.token,
    userInfo: (state) => state.user.userInfo,
    roleId: (state) => state.user.roleId,
    roleInfo: (state) => state.user.roleInfo,
    loginInfo: (state) => state.user.loginInfo,
    token: (state) => state.user.token,
    currdeptInfo: (state) => state.user.currdeptInfo,
    customerInfo: (state) => state.business.customerInfo,
    globalFontSize: (state) => state.globalFontSize,
    lang: (state) => state.lang,
    version: (state) => state.version,
    tenantConfig: (state) => state.tenant.config,
    theme: (state) => state.common.theme,
    ...shoppingCard.getters,
    ...dicts.getters,
    ...business.getters,
    ...print.getters,
    ...face.getters,
  },
  actions: {},
});
